#pragma once
#include "ble.h"
#include "ble_advdata.h"
#define BLE_GAP_ADV_SET_DATA_SIZE_MAX (31)
#define BLE_DEVICE_NAME_LEN ((BLE_GAP_ADV_SET_DATA_SIZE_MAX + 1) - ADV_AD_DATA_OFFSET) /**< Determines the device name length. */
#if 0
#warning debug
#define BLE_DEVICE_FILTER_COUNT 3
#define BLE_DEVICE_ALIVE_SECOND 2
#else
#define BLE_DEVICE_FILTER_COUNT 2
#define BLE_DEVICE_ALIVE_SECOND 2
#endif
typedef struct __Ble_device
{
    int8_t rssi_filter[BLE_DEVICE_FILTER_COUNT];
    int8_t rssi_filter_number;
    int8_t rssi; //>0 means invalid
    bool is_walnutin;
    int distance;
    ble_gap_addr_t addr;
    uint32_t rtc;
    uint8_t name[BLE_DEVICE_NAME_LEN];
} Ble_device;
void distance_estimate_initialize(void);
void distance_estimate_event(ble_evt_t *p_ble_evt);
void distance_estimate_process(void);
#define BLE_DEVICE_COUNT 10

extern Ble_device ble_devices[BLE_DEVICE_COUNT];
